﻿using Sys.Common;
using Sys.Core.Tour;
using Sys.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Car : System.Web.UI.Page
{
    public TourCar model { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string id = Request.QueryString["id"];

            if (!string.IsNullOrEmpty(id))
            {
                model = CarBll.I.GetByKey(id);

                if (model != null)
                {
                    Home mas = Master as Home;

                    string des = StringHelper.NoHTML(model.Content);

                    mas.SetHead(model.Name, model.Name, StringHelper.CutString(des, 100));
                }
                else { model = new TourCar(); }
            }
            else { model = new TourCar(); }
        }
    }

    public string GetImages(string id)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        sb.Append("<ul class='listPic4'>");

        var list = ImageBll.I.GetImages("Car", id);

        foreach (var item in list)
        {
            sb.Append("<li>");
            sb.Append("<a href='#' class='img'><img src='userfiles/car/default/" + item.Img + "'/></a>");
            sb.Append("</li>");
        }

        sb.Append("</ul>");

        return sb.ToString();
    }
}